package com.jiazhong.shixi.book.controller;

import com.jiazhong.shixi.book.bean.User;
import com.jiazhong.shixi.book.mapper.UserMapper;
import com.jiazhong.shixi.book.uilt.JsonResult;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserMapper userMapper;

    @RequestMapping ("/user_denglu")
    public JsonResult user_denglu(User user) {
        User u = userMapper.user_denglu(user);
        if (u == null) {
            JsonResult result = new JsonResult(false,427,null,"账号密码错误");
            return result;
            //登录失败
        }
        else {
            JsonResult result =new JsonResult(true,200,u.getId(),"");
            return result;
            //登陆成功
        }
    }

    @RequestMapping("/user_zhuce")
    public JsonResult user_zhuce(User user) {
        userMapper.user_zhuce(user);
        JsonResult result = new JsonResult(true,201,"success","");
        return result;
    }

}

